import os


from django.test import TestCase

# Create your tests here.
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.dev_settings")
django.setup()
from mineral.models import Inventory
from django.db.models import Sum, Avg

# q = Inventory.objects.all()
# Inventory.objects.annotate()
# for i in q:
#     print(i.__dict__)
#     print(i.total_quantity)
#     print(i.__dict__)

# test 聚合函数

inventory_obj = Inventory.objects.filter(product__product_group=1)
total_quantity = 0
for i in inventory_obj:
    total_quantity += i.total_quantity


# print(inventory_obj.values_list("safe_day", "c"))
